﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Breeding.Api.Application.Command.LambWeaningCommand;

namespace S.Breeding.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LambWeaningController : ControllerBase
    {
        private readonly IMediator mediator;
        public LambWeaningController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 新增羔羊断奶信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddLambWeaning(LambWeaningCreateCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改羔羊断奶信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdLambWeaning(LambWeaningUpdateCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除羔羊断奶信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DelLambWeaning([FromQuery]LambWeaningDeleteCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 批量删除羔羊断奶信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> BatchLambWeaning([FromQuery]LambWeaningBatchCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
    }
}
